package com.coderfans.utils;

import java.io.FileInputStream;
import java.sql.*;
import java.util.*;

/**
 * Created by ${fanchunshuai} on 2017-4-7.
 *
 * @version: V1.0
 * @Desc: JDBC简单工具类
 * @Copyright (c) 2017 58到家-版权所有
 */
public class JdbcUtils {

    public static void main(String[] args) throws Exception {
        String sqlArray [] = new String[4];
        sqlArray[0] = "insert into urls (websitename,websiteurl) values ('test1234555555','asdfasdflansldfnalsdnflansdlf')";
        sqlArray[1] = "insert into urls (websitename,websiteurl) values ('test1234555555','asdfasdflansldfnalsdnflansdlf')";
        sqlArray[2] = "insert into urls (websitename,websiteurl) values ('test1234555555','asdfasdflansldfnalsdnflansdlf')";
        sqlArray[3] = "insert into urls (websitename,websiteurl) values ('test1234555555','asdfasdflansldfnalsdnflansdlf')";
        String sql1 = "SELECT TABLE_NAME,COLUMN_NAME,COLUMN_TYPE AS TYPE,COLUMN_COMMENT FROM information_schema.columns WHERE TABLE_SCHEMA = 'dbdj_authority_test'";
        //com.coderMan.generateBeanFromTable.util.JdbcUtils.initDBConnection("E:\\djworkspace\\openResource\\generateBeanFromTable\\generatebeanfromtable\\generateBeanFromTable\\src\\main\\resources\\jdbc2.properties");

        String sql = "select nick_name,id from csdn_user ";
        //Map<String,String> map = com.coderMan.generateBeanFromTable.util.JdbcUtils.exeQuerySql(sql);
        //System.out.println(map.get("alonesword"));


       /* //String sql = "delete from urls where id in (318657,318658,318659,318660,318661)";

        Map<String,List<String>> map = JdbcUtils.exeSearchSql(sql1);

        Iterator<Map.Entry<String,List<String>>> it =  map.entrySet().iterator();
        while (it.hasNext()){
            System.out.println(it.next().getValue().toString());
        }


        System.out.println("b = "+map.size());
        System.out.println("b = "+map.keySet().toString());*/
        //System.out.println("b = "+map.values().toString());

        //boolean b = JdbcUtils.exeBatchSql(sqlArray);
        //System.out.println("b = "+b);

        //String tableSql = "SELECT TABLE_NAME,TABLE_COMMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'db_csdn'";
        //Map<String,String> map = com.coderMan.generateBeanFromTable.util.JdbcUtils.exeDBSearchSql(tableSql);
        //System.out.println(map.toString());
    }

}
